import {Component, OnInit} from '@angular/core';
import {GlobalEventService} from "../../../server/global-event/global-event.service";
import {FormGroup, Validators, FormBuilder, FormControl} from "@angular/forms";



@Component({
  selector: 'app-user-login',
  templateUrl: './user-login.component.html',
  styleUrls: ['./user-login.component.scss']
})
export class UserLoginComponent implements OnInit {
  winHw:any={};
  validateForm: FormGroup;
  loginBool:boolean = true;
  registerBool:boolean = false;
  forgetBool:boolean = false;



  constructor(private globalEventService: GlobalEventService,
              private fb: FormBuilder) { }

  ngOnInit() {

    this.winHw = {
      width:window.innerWidth,
      height:window.innerHeight
    };
    this.globalEventService.eventArr.windowChange
      .subscribe(res=>{
          this.winHw = res;
      });

    this.validateForm = this.fb.group({
      userName: [null, [Validators.required]],
      password: [null, [Validators.required]],
      remember: [true]
    });

  }

  submitForm(): void {
    for (const i in this.validateForm.controls) {
      this.validateForm.controls[i].markAsDirty();
      this.validateForm.controls[i].updateValueAndValidity();
    }
  }

  /**忘记密码**/
  forgetPass(){
    this.loginBool = false;
    this.forgetBool = true;
  }

  /**注册**/
  registerUser(){
    this.loginBool = false;
    this.registerBool = true;
  }

  /**从注册到登录界面**/
  goLogin(){
    this.loginBool =true;
    this.registerBool = false;
    this.forgetBool = false;
  }









}
